package com.pospi.pospihold.ui.my_ui;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.lany.sp.SPHelper;
import com.pospi.pospihold.App;
import com.pospi.pospihold.R;
import com.pospi.pospihold.ui.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;

import static com.pospi.pospihold.ui.pay_ui.UnionConfig.MERCHANTCODE;
import static com.pospi.pospihold.ui.pay_ui.UnionConfig.TERMINALCODE;

public class UnionActivity extends BaseActivity {
    @Bind(R.id.et_mcode)
    EditText et_mcode;
    @Bind(R.id.et_tcode)
    EditText et_tcode;
    @Bind(R.id.bt_save)
    Button bt_save;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentLayout(R.layout.activity_uinon);
        setTitle("银商支付配置");
        ButterKnife.bind(this);
        String merchantCode= SPHelper.getInstance().getString(MERCHANTCODE,"");
        String terminalCode= SPHelper.getInstance().getString(TERMINALCODE,"");
        if (!merchantCode.isEmpty()) {
            et_mcode.setText(merchantCode);
        }
        if (!terminalCode.isEmpty()) {
            et_tcode.setText(terminalCode);
        }


        bt_save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!et_mcode.getText().toString().trim().isEmpty()&&!et_tcode.getText().toString().trim().isEmpty()) {
                    SPHelper.getInstance().putString(MERCHANTCODE, et_mcode.getText().toString().trim());
                    SPHelper.getInstance().putString(TERMINALCODE, et_tcode.getText().toString().trim());
                    Toast.makeText(UnionActivity.this, "保存成功", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(UnionActivity.this, "请填写完整信息", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
}
